﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XmlSockets.Internal;
namespace LibXmlSocket_UnitTest
{
    public class TestReadContent:IXmlSocketReceiveContent
    {
        private byte[] _buffer;

        public TestReadContent(string testmessage)
        {
            _buffer = XmlSocketConstant.XmlSocketEncoding.GetBytes(testmessage);
        }

        public void BadCase()
        {
            byte[] tmpBuffer = new byte[this._buffer.Length + 1];
            Array.ConstrainedCopy(this._buffer, 0, tmpBuffer, 0, this._buffer.Length);
            tmpBuffer[this._buffer.Length] = 3;
        }

        public int ReceiveLength
        {
            get { return this._buffer.Length; }
        }

        public int Read(byte[] buffer, int offset)
        {
            Array.ConstrainedCopy(this._buffer, 0, buffer, offset, this.ReceiveLength);
            return this.ReceiveLength;
        }
    }
}
